<?php

namespace Database\Seeders;

use App\Models\Archive;
use App\Models\File;
use Illuminate\Database\Seeder;

class FileSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $archive_ids = Archive::pluck('id');
        foreach ($archive_ids as $archive_id) {
            File::factory()->times(random_int(3, 30))->make()->each(function ($file) use ($archive_id) {
                $file->archive_id = $archive_id;
                $file->save();
            });
        }
    }
}
